import org.junit.Test;

import java.lang.reflect.Method;

public class TestDemo {
    @Test
    public void test() throws Exception {
        // 解析注解
        // 首先要获取类的Class对象
        Class c = TestAnnotation.class;
        Method method = c.getDeclaredMethod("test");
        if(c.isAnnotationPresent(MyTest.class)){
            System.out.println("有注解");
        }
        if(method.isAnnotationPresent(MyTest.class)){
            MyTest declaredAnnotation = method.getDeclaredAnnotation(MyTest.class);
            System.out.println(declaredAnnotation.value());
        }
        method.invoke(new TestAnnotation());
    }
}
